﻿using System.Web.Mvc;

namespace Xwltz.Framework.Mvc
{
    public class WebCustomJsonResult : ActionResult
    {
        private readonly string _json;

        public WebCustomJsonResult(string json)
        {
            _json = json;
        }

        public override void ExecuteResult(ControllerContext context)
        {
            if (string.IsNullOrEmpty(_json))
            {
                new EmptyResult().ExecuteResult(context);
                return;
            }
            context.HttpContext.Response.ContentType = "application/json";

            context.HttpContext.Response.Write(_json);
        }
    }
}
